package com.yyds.yygh.hospclient.controller;

import com.yyds.yygh.common.result.Result;
import com.yyds.yygh.hospclient.service.HospitalService;
import com.yyds.yygh.model.hosp.Hospital;
import com.yyds.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    @ApiOperation("获取分页列表")
    @PostMapping("/{page}/{limit}")
    public Result selecthospital(@PathVariable Integer page,
                                 @PathVariable Integer limit,
                                 @RequestBody(required = false)HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pages = hospitalService.selectPage(page, limit, hospitalQueryVo);

        return Result.success(pages);
    }
    @ApiOperation("更新状态")
    @PutMapping("/updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable String id,
                               @PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.success();
    }
    @ApiOperation("医院详情")
    @GetMapping("/show/{id}")
    public Result showHospitalDetail(@PathVariable String id){
        Map<String,Object> map = hospitalService.showDetail(id);
        return Result.success(map);
    }
}
